﻿@model IList<BB.Apostas.ViewModels.ApostaViewModel>
@if (Model.Count > 0)
{
    using (Html.BeginForm("Apostar", "Aposta"))
    {
    @Html.ValidationSummary()    
    <ul data-role="listview" data-filter="true">
        @{int count = 0;}
        @for (int i = 0; i < Model.Count(); i++)
        {    
            <li data-role="list-divider">Data: @Model[i].Date</li>
            <li>
                <p>
                    <strong>
                        @if (Model[i].Fulfilled)
                        {
                            count += 1;
                            @Html.DisplayFor(modelitem => modelitem[i].HomeTeam)
                            @Html.TextBoxFor(modelitem => modelitem[i].HomeBet, new { disabled = true })
                            @Html.DisplayFor(modelitem => modelitem[i].AwayTeam)
                            @Html.TextBoxFor(modelitem => modelitem[i].AwayBet, new { disabled = true })
                        }
                        else
                        {
                            @Html.DisplayFor(modelitem => modelitem[i].HomeTeam)
                            @Html.TextBoxFor(modelitem => modelitem[i].HomeBet)                            
                            @Html.DisplayFor(modelitem => modelitem[i].AwayTeam)
                            @Html.TextBoxFor(modelitem => modelitem[i].AwayBet)
                        }
                        @Html.HiddenFor(modelitem => modelitem[i].ApostaId)
                        @Html.HiddenFor(modelitem => modelitem[i].JogoId)
                        @Html.HiddenFor(modelitem => modelitem[i].Date)
                    </strong>
                </p>
                <p>
                    <strong>
                        @Html.Label("Pontos")
                    </strong>
                </p>
                <p>
                    <strong>
                        @Html.DisplayTextFor(modelitem => modelitem[i].Score)
                    </strong>
                </p>
            </li>
        }
    </ul>    
        if (count != System.Web.Configuration.WebConfigurationManager.AppSettings["NumJogos"].AsInt())
        {
    
    <p>
        <span>&nbsp;</span>
        <input type="submit" value="Apostar" class="submit" />
    </p>
    
        }
    }
}
else
{
    <h3>Apostas ainda nao disponiveis.
    </h3>
}